<?php
namespace Swostar\Message\Http;

use Swoole\Http\Request as SwooleRequest;
use Swostar\Foundation\Application;

class Request
{
    // 请求相关的服务器信息。
    protected $server;
    protected $swooleRequest;

    // 请求方法
    protected $mothed;

    // 请求路径
    protected $uriPath;

    public function getMethod()
    {
        return $this->mothed;
    }

    public function getUriPath()
    {
        return $this->uriPath;
    }

    /**
     * 请求信息处理
     * @param SwooleRequest $request 
     * @return mixed|Application 
     */
    public static function init(SwooleRequest $request)
    {

        $self = app('httpRequest');

        $self->swooleRequest = $request;
        $self->server = $request->server;
        $self->mothed = $self->server['request_method'] ?? '';
        $self->uriPath = $self->server['request_uri'] ?? '';

        return $self;
    }



}
